package com.mql.mall.mallsearch.controller;

import com.mql.mall.mallcommon.to.es.SkuEsModel;
import com.mql.mall.mallcommon.utils.R;
import com.mql.mall.mallsearch.Service.ProductSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RequestMapping("/search/save")
@RestController
public class ElasticSaveController {

    @Autowired
    ProductSaveService productSaveService;
    //上架
    @PostMapping("/product")
    public R productStatusUp(@RequestBody List<SkuEsModel> skuEsModels){

        try {
            productSaveService.productStatusUp(skuEsModels);
        } catch (IOException e) {
            return R.error();
        }
        return R.ok();
    }
}
